 (function($){
	$.fn.lin_gaplessPic=function(options)
	{
		var opts=$.extend({}, $.fn.lin_gaplessPic.defaults, options);
		return this.each(function()
		{
      	    var $this=$(this);
			var $scrollObj=$(opts.scrollObj,$this),
			$target=$scrollObj.find(opts.targetObj),
			_targetSize,
			_num,
			_autoPlay,
			_stop = false,
			$preBtn=$(opts.preBtn,$this),
			$nextBtn=$(opts.nextBtn,$this),
			_targetSize=$target.outerWidth()+opts.difference,
			_num=$target.length;		
			$scrollObj.css("width",_num*_targetSize); 	 
			$preBtn.click(function(){
				xToLeft();
			});	
			$nextBtn.click(function(){
				xToRight();
			});
			
			function  xToRight()
			{
				if(!$scrollObj.is(":animated"))
				{
					$scrollObj.animate({left:"-"+_targetSize},opts.easing,function(){
					$scrollObj.find(opts.targetObj+":first").appendTo($scrollObj);
						$scrollObj.css({"left":"0"});
						if(opts.autoPlay&&!_stop)_autoPlay=setTimeout(xToLeft,opts.timer);
					});
				}	
			}
			
			function xToLeft()
			{
				if(!$scrollObj.is(":animated"))
				{
				    $scrollObj.find(opts.targetObj+":last").prependTo($scrollObj);
					$scrollObj.css({"left":-_targetSize});
					$scrollObj.stop().animate({"left":0},opts.easing,function(){
						if(opts.autoPlay&&!_stop)_autoPlay=setTimeout(xToRight,opts.timer);
					});
					
				}
			}	
			// 如果滑鼠移入 $block 時
			$this.hover(function(){
				_stop = true;
				clearTimeout(_autoPlay);
				$preBtn.fadeIn();
				$nextBtn.fadeIn();
			}, function(){
				_stop = false;
				_autoPlay = setTimeout(xToRight,opts.timer);
				$preBtn.fadeOut();
				$nextBtn.fadeOut();				
			});
			
			if(opts.autoPlay){_autoPlay = setTimeout(xToRight,opts.timer);}		
		});
	};
	
	$.fn.lin_gaplessPic.defaults=
	{
		scrollObj:'.lin_scrollObj',
		targetObj:"li",//被控制添加子对象
		preBtn:'.lin_btnPre',
		nextBtn:'.lin_btnNext',
		autoPlay:true,
		difference:0,//宽度补差值
		speed:720,
		timer:3000,
		easing:'easeInOutExpo'
	};
})(jQuery); 